const WebSocket = require('ws')

const ws = new WebSocket('ws://localhost:8900');  // 连接到WebSocket服务器

let firstMessage, secondMessage;

ws.onopen = function () {
    console.log('Connected to the WebSocket server');
};

ws.onmessage = function (event) {
    if (!firstMessage) {
        firstMessage = event.data;
    } else {
        secondMessage = event.data;
        console.log('Received messages:', firstMessage, secondMessage);
    }
};

ws.onclose = function () {
    console.log('Connection to the WebSocket server is closed');
};
